<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Api\IndexApi;
use Illuminate\Support\Facades\Redis;
use App\Http\Controllers\Api\SearchApi;
use App\Http\Controllers\Home\ShowLinksController;

/**
 * @author [wt1ao] <[424356452@qq.com]>
 */
class HomeIndex extends Controller
{
    //显示首页
    public function index()
    {
        $index = new IndexApi();

        //查询友情链接数据
        $link = new ShowLinksController;
        $linksArray = $link->index();

        //查询站点信息
    	  $sate = IndexApi::getSate();

        //查询父级分类信息
        $types = $index->getTypes();

        //查询男鞋分类信息
        $manTypes = $index->getManTypes('男子');

        //查询男鞋分类第一个分类下的商品信息
        $manGoods = $index->getTypeGoods($manTypes[0]['id']);

        //查询女鞋的分类信息
        $womanTypes = $index->getManTypes('女子');

        //查询女鞋分类第一个分类的商品信息
        $womanGoods = $index->getTypeGoods($womanTypes[0]['id']);

        //查询轮播图信息
        $loops = $index->getLoopPics();

        //实例化搜索类
        $search = new SearchApi('abc');

          //查询热搜词
        $HotSearch = $search->getHot();

    	  return view('Home.goods-index', ['sate' => $sate,
                                       'types' => $types,
                                       'manTypes' => $manTypes,
                                       'womanTypes' => $womanTypes,
                                       'manGoods' => $manGoods,
                                       'womanGoods' => $womanGoods,
                                       'loops' => $loops,
                                       'linksArray' => $linksArray,
                                       'HotSearch' => $HotSearch
                                     ]);
    }
}
